﻿using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Entity.TD;
using Coldairarrow.Util;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;


namespace Coldairarrow.Business.PB
{
    public partial interface IPB_ProductionOrderBusiness
    {
        Task<PageResult<PB_ProductionOrder>> GetDataListAsync(PageInput<ConditionDTO> input);
        Task<PageResult<Entity.PB.PB_ProductionOrderDTO>> GetDataListShowDeptNameAsync(PageInput<PB_ProductionOrderConditionDTO> input);
        /// <summary>
        /// sql获取任务单信息
        /// </summary>
        /// <param name="input">参数</param>
        /// <returns></returns>
        Task<PageResult<Entity.PB.PB_ProductionOrderDTO>> GetDataPercentageList(PageInput<PB_ProductionOrderConditionDTO> input);
        Task<PB_ProductionOrder> GetTheDataAsync(string id);
        /// <summary>
        /// 大屏显示当月生产计划数量
        /// </summary>
        /// <param name="Month">前第几月</param>
        /// <returns></returns>
        Coldairarrow.Entity.DTO.ScreenDisplayProgressDTO GetMonthPlanNums(int Month);
        /// <summary>
        /// 大屏显示当月生产计划重量(吨)
        /// </summary>
        /// <param name="Month">前第几月</param>
        /// <returns>当月生产计划重量(吨)</returns>
        Coldairarrow.Entity.DTO.ScreenDisplayProgressDTO GetMonthPlanWeights(int Month);
        /// <summary>
        /// 大屏显示当日总计划重量(吨)
        /// </summary>
        /// <param name="Day"></param>
        /// <returns></returns>
        Coldairarrow.Entity.DTO.ScreenDisplayValueDTO GetTodayPlanWeight(int Day);
        /// <summary>
        /// 大屏显示当日总完成重量(吨)
        /// </summary>
        /// <param name="Day"></param>
        /// <returns></returns>
        Coldairarrow.Entity.DTO.ScreenDisplayValueDTO GetTodayFinishWeight(int Day);
        /// <summary>
        /// 大屏显示当日总计划完成率
        /// </summary>
        /// <param name="Day"></param>
        /// <returns></returns>
        Coldairarrow.Entity.DTO.ScreenDisplayValue3DTO GetTodayFinishRate(int Day);
        /// <summary>
        /// 大屏显示当月指定车间总完成重量(吨)
        /// </summary>
        /// <param name="Month">前第几月</param>
        /// <param name="WorkShop">车间名称</param>
        /// <returns></returns>
        Coldairarrow.Entity.DTO.ScreenDisplayValueDTO GetMonthFinishWeightByWorkShop(int Month, string WorkShop);
        Task AddDataAsync(PB_ProductionOrder data);
        Task UpdateDataAsync(PB_ProductionOrder data);
        Task DeleteDataAsync(List<string> ids);
        Task<List<PB_ProductionOrder>> GetPDADataListAsync(PageInput<ConditionDTO> input);
        Task<string> GetDataLisJson(string id);//返回json生产订单
        IQueryable<T> GetQueryable<T>() where T : class, new();
        Task AddData(Entity.DTO.PB_ProductionOrderListDTO data);
        /// <summary>
        /// 保存未派工的生产任务单信息
        /// </summary>
        /// <param name="data">数据</param>
        /// <returns></returns>
        Task UpdateTaskDetailList(Entity.DTO.PB_ProductionOrderListUpdateDTO data);
        /// <summary>
        /// 任务单变更依据任务单明细id替换新的物料id 并生成原始物料任务明细
        /// </summary>
        /// <param name="data">数据源</param>
        /// <returns></returns>

        Task UpdateData(Entity.DTO.PB_ProductionOrderListDTO data);
        Task<PB_ProductionOrderList> GetDataListInfo(string ParentId);
        Task<PB_ProductionOrderList> GetDataListDetailed(string ParentId);
        Task<AjaxResult> SaveEditTOexamineOrder(string idIn, int judge);
        //查找生产订单
        Task<PageResult<PB_ProductionOrder>> GetDataSelectAsync(PageInput<ConditionDTO> input);
        //生产领料查询
        Task<PB_ProductionOrderList> GetPDADataListInfo(string cateqrcode);
        Task AddPDADataAsync(TD_OutStorage data);

        /// <summary>
        /// 生产任务单根据设计清单选择物料（明细汇总）
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<DesignMaterialDTO>> GetDesignMaterialListAsync(PageInput<DesignMaterialConditionDTO> input);

        /// <summary>
        /// 生产任务单根据设计清单选择物料（明细）
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<DesignMaterialDTO>> GetDesignMaterialDetailListAsync(PageInput<DesignMaterialConditionDTO> input);



        /// <summary>
        /// 获取车间名称
        /// </summary>
        /// <param name="WorkShop"></param>
        /// <returns></returns>
        Task<List<Entity.DTO.ProductionPlanWorkShop>> GetProductionPlanWorkShop(string WorkShop);
        /// <summary>
        /// 进度
        /// </summary>
        /// <param name="WorkShop"></param>
        /// <returns></returns>
        Task<List<Entity.DTO.GetPassRate>> Gethege(string WorkShop);
        /// <summary>
        /// 整体合格率
        /// </summary>
        /// <param name="WorkShop"></param>
        /// <returns></returns>
        Task<List<Entity.DTO.OverallQualificationRate>> GerProjectRate(string WorkShop);
        /// <summary>
        /// 获取报工列表
        /// </summary>
        /// <param name="WorkShop"></param>
        /// <returns></returns>
        Task<List<WorkReportlist>> GetWorkReportlist(string WorkShop);
        /// <summary>
        /// 获取报工列表
        /// </summary>
        /// <param name="WorkShop"></param>
        /// <returns></returns>
        Task<List<Statisticaldata>> GetStatisticaldata(string WorkShop);


        #region   组件生产任务单

        /// <summary>
        /// 获取需要组件的BOM物料信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<BomMaterialDTO>> GetBomMaterialListAsync(PageInput<OrderBomMaterialConditionDTO> input);

        #endregion

        #region 生产任务单明细派工详情

        /// <summary>
        /// 获取生产任务单明细的派工信息
        /// </summary>
        /// <param name="orderdetailId">任务单明细Id</param>
        /// <returns></returns>
        Task<List<OrderDetailDispatchDetailDTO>> GetOrderDetailDispatchDetailListAsync(string orderdetailId);
        /// <summary>
        /// 生产任务单改单
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task ChangeTaskDetail(ChangeTaskDetailDto data);

        /// <summary>
        /// 生产任务单改单打印流转单
        /// </summary>
        /// <param name="DispatchDtailId">派工单明细id</param>
        /// <param name="SubId">工序id</param>
        /// <returns></returns>
        Task<List<CirculationDetails>> PrintCirculationDetails(string DispatchDtailId,string SubId);

        Task ReplaceTask(Entity.DTO.PB_ProductionOrderListDTO data);
        #endregion

    }

    /// <summary>
    /// 生产任务单根据设计清单选择物料
    /// </summary>
    public class DesignMaterialDTO
    {
        /// <summary>
        /// 物料ID
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 设计清单Id
        /// </summary>
        public string ParentId { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string Spec { get; set; }

        /// <summary>
        /// 成品编码
        /// </summary>
        public string ProductCode { get; set; }

        /// <summary>
        /// 设计清单设计数量
        /// </summary>
        public double? Nums { get; set; }

        /// <summary>
        /// 设计清单应发数量
        /// </summary>
        public double? RealNums { get; set; }

        /// <summary>
        /// 库存剩余数量
        /// </summary>
        public double? ScanNum { get; set; }

        /// <summary>
        /// 库存占用数量
        /// </summary>
        public double? Nums_R { get; set; }

        /// <summary>
        /// 库存可用数量
        /// </summary>
        public double? AvailableQuantity { get; set; }

        /// <summary>
        /// 已生产数量
        /// </summary>
        public double? CompleteNums { get; set; }

        /// <summary>
        /// 是否需要生产
        /// </summary>
        public int? ProductionOrNot { get; set; }

        /// <summary>
        /// 剩余生产数量
        /// </summary>
        public double? SurplusProduction { get; set; }

        /// <summary>
        /// 设计清单明细状态
        /// </summary>
        public int? State { get; set; }

        /// <summary>
        /// 物料使用状态(0未启用 ，1启用)
        /// </summary>
        public bool? UsageStatus { get; set; }

        /// <summary>
        /// 单位组Id
        /// </summary>
        public string UnitGroupId { get; set; }

        /// <summary>
        /// 单位组名称
        /// </summary>
        public string UnitGroupName { get; set; }

        /// <summary>
        /// 物料包装数量
        /// </summary>
        public double? PackageNum { get; set; }

    }

    public class DesignMaterialConditionDTO
    {
        public string Condition { get; set; }
        public string Keyword { get; set; }

        /// <summary>
        /// 设计清单ID
        /// </summary>
        public string DesignId { get; set; }

        /// <summary>
        /// 是否生产
        /// </summary>
        public int? IsProduction { get; set; }

        /// <summary>
        /// 设计清单明细状态(0-基础；1-不加；2-减少)
        /// </summary>
        public int? State { get; set; }
        /// <summary>
        /// 单位组Id
        /// </summary>
        public string UnitGroupId { get; set; }
    }



    #region   组件生产任务单

    /// <summary>
    /// 生产任务单获取第一级BOM物料信息
    /// </summary>
    public class BomMaterialDTO
    {
        /// <summary>
        /// 物料Id
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string Spec { get; set; }

        /// <summary>
        /// 成品编码
        /// </summary>
        public string ProductCode { get; set; }

        /// <summary>
        /// 单位组Id
        /// </summary>
        public string UnitGroupId { get; set; }

        /// <summary>
        /// 单位组名称
        /// </summary>
        public string UnitGroupName { get; set; }

    }

    public class OrderBomMaterialConditionDTO
    {
        public string Condition { get; set; }
        public string Keyword { get; set; }

        /// <summary>
        /// 成品编码
        /// </summary>
        public string ProductCode { get; set; }
    }

    #endregion

    #region 生产任务单明细派工详情DTO

    public class OrderDetailDispatchDetailDTO
    {
        /// <summary>
        /// 派工单明细Id
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 派工单Id
        /// </summary>
        public string ParentId { get; set; }

        /// <summary>
        /// 员工
        /// </summary>
        public string StaffName { get; set; }

        /// <summary>
        /// 工序Id
        /// </summary>
        public string SubId { get; set; }

        /// <summary>
        /// 工序名称
        /// </summary>
        public string SubName { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 是否半成品
        /// </summary>
        public string IsVirtualkey { get; set; }

        /// <summary>
        /// 是否成品
        /// </summary>
        public string IsProduct { get; set; }

        /// <summary>
        /// 隶属成品Id
        /// </summary>
        public string SubordinateProduct { get; set; }

        /// <summary>
        /// 隶属成品
        /// </summary>
        public string SubordinateProductName { get; set; }

        /// <summary>
        /// 派工数量
        /// </summary>
        public double? Nums { get; set; }

        /// <summary>
        /// 已报工数量
        /// </summary>
        public double? WorkReportQuantity { get; set; }

        /// <summary>
        /// 生产成品数量
        /// </summary>
        public double? Productionquantity { get; set; }

        /// <summary>
        /// 已生产成品数量
        /// </summary>
        public double? CompleteNums { get; set; }

        /// <summary>
        /// 派工人姓名
        /// </summary>
        public string CreatorRealName { get; set; }

    }
    /// <summary>
    /// 任务单改制变更
    /// </summary>
public  class   ChangeTaskDetailDto{
        /// <summary>
        /// 任务单明细id
        /// </summary>
        public string OrderDetailId { get; set; }
        /// <summary>
        /// 替换之前的物料
        /// </summary>
        public string ReplacementMateraiId { get; set; }
        /// <summary>
        /// 替换之后的物料
        /// </summary>
        public string OriginalMateraiId { get; set; }
        /// <summary>
        /// 替换备注
        /// </summary>
        public string Remarks { get; set; }
    }
    #endregion


}